package cn.wangyu.tcc.record.controller;

import cn.wangyu.tcc.record.domain.TransactionalRecord;
import cn.wangyu.tcc.record.service.TransactionalRecordService;
import com.baomidou.mybatisplus.extension.api.R;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangyu
 * @version 1.0
 * @date 2022/5/23 23:06
 */
@RestController
@RequestMapping("/transaction/record")
@RequiredArgsConstructor(onConstructor = @_(@Autowired))
public class TransactionalRecordController {

    private final TransactionalRecordService transactionalRecordService;

    @PostMapping("/")
    public R<TransactionalRecord> add (TransactionalRecord record) {
        return R.ok(transactionalRecordService.add(record));
    }

    @GetMapping("/getByXid")
    public R<TransactionalRecord> getByXid(@RequestParam("xid") String xid){
        return R.ok(transactionalRecordService.getByXid(xid));
    }
}
